from media.lib.views import FileUploadFormMixin
from project.views.lib import (
    ProjectSubIndexRedirectView,
    ProjectSubAuditDetailViewNoPK,
    ProjectSubAuditFormPostAPIViewNoPK,
    HTMXProjectSubCreateFormViewNoPK,
    HTMXProjectSubUpdateFormViewNoPK,
    template_path
)

from .. import models
from .. import forms

class ImplementIndexView(ProjectSubIndexRedirectView):
    model = models.Implement
    detail_view_name = "project:implement/detail"
    create_view_name = "project:implement/create"

class ImplementCreateView(
    FileUploadFormMixin,
    HTMXProjectSubCreateFormViewNoPK
):
    form_class = forms.ImplementForm
    template_name = template_path("detail_form_base.html")
    create_view_name = "project:implement/create"
    detail_view_name = "project:implement/detail"

class ImplementDetailView(ProjectSubAuditDetailViewNoPK):
    model = models.Implement
    form_class = forms.ImplementForm
    template_name = template_path("implement/detail.html")
    audit_permission = "user.can_manage_projects"
    audit_viewname = "project:implement/audit"


class ImplementUpdateView(
    FileUploadFormMixin,
    HTMXProjectSubUpdateFormViewNoPK
):
    model = models.Implement
    form_class = forms.ImplementForm
    update_view_name = "project:implement/update"
    detail_view_name = "project:implement/detail"



class ImplementAuditFormPostAPIView(ProjectSubAuditFormPostAPIViewNoPK):
    model = models.Implement

